//
//  MQSocietyDetailCell.m
//  MQ
//
//  Created by lanou on 15/10/27.
//  Copyright © 2015年 徐永祥. All rights reserved.
//

#import "MQSocietyDetailCell.h"
#import <UIImageView+WebCache.h>
@implementation MQSocietyDetailCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle =  UITableViewCellSelectionStyleNone;
        _pictureView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 150, 100)];
        [self.contentView addSubview:_pictureView];
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(160, 10, screen_width-150-20, 50)];
        _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
        _titleLabel.numberOfLines = 0;
        [self.contentView addSubview:_titleLabel];
        
        _timeView = [[UIImageView alloc]initWithFrame:CGRectMake(160, 82.5, 17.5, 17.5)];
        _timeView.alpha = 0.5;
        _timeView.image = [UIImage imageNamed:@"shijian"];
        [self.contentView addSubview:_timeView];
        
        
        _timeLabel = [[ UILabel alloc]initWithFrame:CGRectMake(180, 80, 40, 20)];
        _timeLabel.font =[UIFont fontWithName:@"Helvetica-Bold" size:13];
        _timeLabel.alpha = 0.5;
        [self.contentView addSubview:_timeLabel];
        
        _playTimeView = [[UIImageView alloc]initWithFrame:CGRectMake(230, 80, 25, 25)];
        _playTimeView.alpha = 0.5;
        _playTimeView.image = [UIImage imageNamed:@"playTime"];
        [self.contentView addSubview:_playTimeView];
        
        
        _playTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(255, 80, 60, 20)];
        _playTimeLabel.font =[UIFont fontWithName:@"Helvetica-Bold" size:13];
        _playTimeLabel.alpha = 0.5;
        [self.contentView addSubview:_playTimeLabel];
    }
    return self;    
}

-(void)configCellWithModel:(MQSocietyDetailModel *)model
{

    for (int i = 0; i<model.files.count; i++) {
        if ([[[model.files[i] objectForKey:@"mediaUrl"] substringWithRange:NSMakeRange(((NSString *)[model.files[i] objectForKey:@"mediaUrl"]).length-3, 3)] isEqualToString:@"jpg"]) {
            [self.pictureView sd_setImageWithURL:[NSURL URLWithString:[model.files[i] objectForKey:@"mediaUrl"]]];

        }
    }
    
    self.titleLabel.text = model.name;
    self.timeLabel.text = [NSString stringWithFormat:@"%02ld:%02ld",model.duration/60,model.duration%60];
    self.playTimeLabel.text = [NSString stringWithFormat:@"%.01f万",model.playTime/10000.0];
  
    
    
}

-(void)configCellWithHotModel:(MQSocietyHeadModel *)model
{

    [self.pictureView sd_setImageWithURL:[NSURL URLWithString:model.image]];
    self.titleLabel.text = model.title;
    self.playTimeLabel.text = [NSString stringWithFormat:@"%.01f万",model.playTime/10000.0];
    self.timeLabel.text =[NSString stringWithFormat:@"%02ld:%02ld",model.memberItem.duration/60,model.memberItem.duration%60];
    

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
